import base64
from Crypto.Util.Padding import pad
from Crypto.Cipher import AES


def aes_cipher(key, aes_str):
    aes = AES.new(key.encode('utf-8'), AES.MODE_ECB)
    pad_pkcs7 = pad(aes_str.encode('utf-8'), AES.block_size,
                    style='pkcs7')
    encrypt_aes = aes.encrypt(pad_pkcs7)
    encrypted_text = str(base64.encodebytes(
        encrypt_aes), encoding='utf-8')
    encrypted_text_str = encrypted_text.replace("\n", "")
    return encrypted_text_str


def encrypt(text):
    key = 'wrdvpnisthebest!'.encode()
    cryptos = AES.new(key, AES.MODE_CFB,
                      'wrdvpnisthebest!'.encode(), segment_size=128)
    cipher_text = cryptos.encrypt(text.encode())
    return 'wrdvpnisthebest!'.encode().hex()+cipher_text.hex()
